package com.haoxin.ai_course.modules.course.controller.admin;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.haoxin.ai_course.common.annotation.SysLog;
import com.haoxin.ai_course.common.base.AbstractController;
import com.haoxin.ai_course.common.utils.HttpJsonResult;
import com.haoxin.ai_course.common.utils.R;
import com.haoxin.ai_course.modules.course.biz.AcCourseBusiness;
import com.haoxin.ai_course.modules.course.entity.AcCourse;
import com.haoxin.ai_course.modules.course.entity.VO.AcCourseVO;
import com.haoxin.ai_course.modules.course.service.AcCourseService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;



/**
 * 课程表
 * 
 * @author xingxiangguo
 * @email bugcn@qq.com
 * @date 2022-06-06 09:44:48
 */
@RestController
@AllArgsConstructor
@RequestMapping("/course/accourse")
@Api(value="api",tags="后台-课程管理")
public class AdminAcCourseController  extends AbstractController {
    private final  AcCourseService acCourseService;
    @Autowired
    AcCourseBusiness acCourseBusiness;
    /**
     * 列表
     */
    @GetMapping("/list")
    @ApiOperation("课程分页列表")
    public R list(@RequestParam Map<String, Object> params){
        //查询列表数据
        QueryWrapper<AcCourse> queryWrapper = new QueryWrapper<>();
        IPage<AcCourse> sysConfigList = acCourseService.page(mpPageConvert.<AcCourse>pageParamConvert(params),queryWrapper);
        return R.ok().put("page", mpPageConvert.pageValueConvert(sysConfigList));
    }


    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    @SysLog("根据id查询课程详情")
    public R info(@PathVariable("id") Integer id){
        return R.ok().put("acCourse", acCourseService.getById(id));
    }


    /**
     * 新增课程表
     */
    @SysLog("新增课程表数据")
    @PostMapping("/save")
    public R save(@RequestBody AcCourse acCourse){
        acCourseService.save(acCourse);
        return R.ok();
    }


    /**
     * 修改
     */
    @SysLog("修改课程表数据")
    @RequestMapping("/update")
    public R update(@RequestBody AcCourse acCourse){
		acCourseService.updateById(acCourse);
        return R.ok();
    }


    /**
     * 删除
     */
    @SysLog("删除课程表数据")
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] ids){
		acCourseService.removeByIds(Arrays.asList(ids));
        return R.ok();
    }
}
